package com.study.websocket1.service;

import javax.websocket.ContainerProvider;
import javax.websocket.WebSocketContainer;
import java.net.URI;

/**
 * @author Mayjean
 */
public class ClientStart {

    public static void main(String[] args) {
        try {
            WebSocketContainer container = ContainerProvider.getWebSocketContainer();

            int i = 0;
                MyClient client = new MyClient();
                container.connectToServer(client, new URI("ws://127.0.0.1:8081/myHandler"));
//            container.connectToServer(client, new URI("ws://127.0.0.1:8080/ws/asset/9527"));
                // container.setDefaultMaxSessionIdleTimeout(5000L);
                int index = 0;
                while (index++ < 10) {
                    client.send("我是请求消息: "+i);
                    Thread.sleep(2000);
                }
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}